package views

import (
	"errors"
	"net/http"
	"strconv"
	"strings"

	"gitee.com/Yu-eng/Myproject/my-go-blog/common"
)

func (*HTMLApi) Detail(w http.ResponseWriter, r *http.Request) {
	detail := common.Template.Detail

	//获取路径参数
	path := r.URL.Path
	//将路径转化为cid
	pIdStr := strings.TrimPrefix(path, "/p/")
	//得到的是 7.html类似的数据
	pIdStr = strings.TrimSuffix(pIdStr, ".html")
	pid, err := strconv.Atoi(pIdStr)
	if err != nil {
		//出错在页面上写入
		detail.WriteError(w, errors.New("不识别此请求路径!"))
		return
	}

}
